package com.example.xiaomi.service;
import com.example.xiaomi.entity.AdminInfo;
import com.example.xiaomi.mapper.AdminMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class AdminServiceImpl implements AdminService{
    @Autowired
    private AdminMapper mapper;

    @Override
    public PageInfo<AdminInfo> findAdminPages(Integer pageNum, Integer pageSize, String adminname) {
        PageHelper.startPage(pageNum,pageSize);
        List<AdminInfo> lists = mapper.findAllAdmin(adminname);
        PageInfo<AdminInfo> pageInfo = new PageInfo<>(lists);
        return pageInfo;
    }


    @Override
    public List<AdminInfo> findAllAdmin(String adminname) {
        List<AdminInfo> allAdmin= mapper.findAllAdmin(adminname);
        return allAdmin;
    }


    @Override
    public AdminInfo findAdminBYID(Integer adminid) {
        AdminInfo info = mapper.findAdminBYID(adminid);
        return info;
    }

    @Override
    public Integer deleteBYID(Integer adminid) {

        return mapper.deleteBYID(adminid);
    }



    @Override
    public Integer updateAdmin(AdminInfo admin) {

        return mapper.updateAdmin(admin);
    }
}
